#include <stdlib.h>
#include "optim.h"
#include "scalar_priv.h"

typedef struct SGD
{
    ScalarPtr obj;
    double lr;
} SGD;

SGDPtr NewSGD(ScalarPtr p, double lr)
{
    SGDPtr optim = malloc(sizeof(SGD));
    optim->obj = p;
    optim->lr = lr;
}
void ZeroGrad(SGDPtr p)
{
    p->obj->grad = 0;
}

void Step(SGDPtr p)
{
    p->obj->val += -p->lr * p->obj->grad;
}